﻿using System;
using CH.FourBoards.LagerWalti.Persistence.Entities;

namespace CH.FourBoards.LagerWalti.Persistence.DataAccess.EntityProviders
{
    internal class EntityProviderFactory
    {
        private readonly DataContext _context;

        public EntityProviderFactory(DataContext context)
        {
            _context = context;
        }

        public IEntityProvider GetForType<T>()
        {
            if (typeof(T) == typeof(Product)) {
                return new ProductProvider(_context);
            }
            if (typeof(T) == typeof(Category)) {
                return new CategoryProvider(_context);
            }
            if (typeof(T) == typeof(Transaction)) {
                return new TransactionProvider(_context);
            }

            throw new ArgumentException(string.Format("Invalid Type: {0}", typeof(T).Name));
        }
    }
}
